package com.nervenets.web.controller.buildPromotion;

import com.nervenets.web.enumeration.CheckStatus;
import com.nervenets.web.hibernate.domain.BuildPromotion;
import com.nervenets.web.redis.GlobalService;
import com.nervenets.web.redis.domain.BuildingStored;
import com.nervenets.web.redis.domain.admin.ManagerStored;
import lombok.Data;

import java.io.Serializable;

@Data
public class BuildPromotionDto implements Serializable {
    private long id;
    private int createTime;
    private long managerId;
    private String managerName;
    private long buildingId;
    private String buildingName;
    private String title;
    private String cover;
    private String content;
    private boolean enable;
    private int queue;
    private CheckStatus checkStatus;
    private String remark;

    public BuildPromotionDto(BuildPromotion promotion, GlobalService globalService) {
        this.id = promotion.getId();
        this.createTime = promotion.getCreateTime();
        this.managerId = promotion.getManagerId();
        final ManagerStored manager = globalService.getManager(this.managerId);
        if (null != manager) {
            this.managerName = manager.getName();
        }
        this.buildingId = promotion.getBuildingId();
        final BuildingStored building = globalService.getBuilding(this.buildingId);
        if (null != building) {
            this.buildingName = building.getName();
        }
        this.title = promotion.getTitle();
        this.cover = promotion.getCover();
        this.content = promotion.getContent();
        this.enable = promotion.isEnable();
        this.queue = promotion.getQueue();
        this.checkStatus = promotion.getCheckStatus();
        this.remark = promotion.getRemark();

    }
}
